#ifndef _2_69_H
#define _2_69_H

/**
 * Do rotating right shift. Assume 0 <= n < w;
 * Examples when x = 0x12345678 and w = 32:
 *          n = 4 --> 0x81234567, n = 20 -->0x45678123;
 */

unsigned rotate_right(unsigned x, int n){
    int mask = (1 << n) - 1;
    unsigned low = x & mask;

    return (x >> n) | low << (32 - n);
}

#endif // _2_69_H

